package cn.tx.redis7.controller;

import cn.tx.redis7.service.GeoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.GeoResults;
import org.springframework.data.geo.Point;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author jizenan
 * @date 2025/6/3
 * Description:
 */
@Api(tags = "美团地图附近的酒店推送GEO")
@RestController
@Slf4j
public class GeoController {

    @Resource
    GeoService geoService;

    @ApiOperation("添加坐标geoAdd")
    @GetMapping("/geoAdd")
    public String geoAdd(){
        return geoService.geoAdd();
    }

    @ApiOperation("获取经纬度坐标geopos")
    @GetMapping("/geopos")
    public Point position(String member){
        return geoService.position(member);
    }

    @ApiOperation("获取经纬度生成的base32编码值geohash")
    @GetMapping("/geohash")
    public String hash(String member){
        return geoService.hash(member);
    }

    @ApiOperation("获取两个给定位置之间的距离")
    @GetMapping("/geodist")
    public Distance distance(String member1, String member2){
        return geoService.distance(member1,member2);
    }

    @ApiOperation("通过经度纬度查找北京王府井附近的")
    @GetMapping("/georadius")
    public GeoResults radiusByxy(){
        return geoService.radiusByxy();
    }

    @ApiOperation("通过地方查找附近,本例写死天安门作为地址")
    @GetMapping("/georadiusByMember")
    public GeoResults radiusByMember(){
        return geoService.radiusByMember();
    }

}
